use specs::{ Entity, ReadStorage };
use crate::validators::validator::Validator;
use crate::res::observing_storage::Observing;

pub struct ObservingValidator;

impl<'a> Validator<'a> for ObservingValidator {
    type SystemData = (
        ReadStorage<'a, Observing>
    );

    fn validate(&mut self, observings: &Self::SystemData, performer: Entity, target: Entity) -> bool {
        if let Some(observing) = observings.get(performer) {
            observing.0.contains(&target.id())
        } else {
            false
        }
    }
}